<template>
  <div id="app" class="evaluate">
    <div class="files-title">
      <h3>成长评价</h3>
      <p>{{ searchData.stuName }} 在 {{ searchData.semesterName }} 被评价 <span>{{evaluateNum}} 次</span></p>
    </div>
    <line-bar ref="lineBar" :chartData="chartData" :YAxis="YAxis" v-on="$listeners"></line-bar>
  </div>
</template>
<script>
import LineBar from "../modules/line-bar.vue";
import { StudengFiles } from '@/utils/skStudentFilesMixin.js'
export default {
  name: 'evaluate',
  mixins:[StudengFiles],
  data() {
    return {
      url: {
        query: '/management/skStudentEvaluation/getStudentEvaluationByMonth',
      },
      chartData:[
        {
          legendTitle:"五颗花",
          type:"bar",
          color:["#A78DFE","#FF3976"]
        },
        {
          legendTitle:"四颗花",
          type:"bar",
          color:["#84F8FF","#8965FD"]
        },
        {
          legendTitle:"三颗花",
          type:"bar",
          color:["#B7FF8F","#40D1FF"]
        },
        {
          legendTitle:"两颗花",
          type:"bar",
          color:["#FE909D","#FFCB01"]
        },
        {
          legendTitle:"一颗花",
          type:"bar",
          color:["#B7FF8F","#FBE17D"]
        }
      ],
      YAxis:[
        {
          name:"次",
          position:"left"
        }
      ],
      evaluateNum:0
    }
  },
  components: {
    LineBar
  },
  props:["dataForm","semesterName","className"],
  filters: {},

  computed: {},

  created() {},

  activated() {},

  mounted() {
  },

  methods: {
    // /查看单个幼儿数据
    async initStudentChart(){
      let data = await this.queryData();
      let categorys = [],xData = [];
      const monthColumns = this.dataForm.daysColums;
      let arr1 = [],arr2 = [],arr3 = [],arr4 = [],arr5 = [];
      this.evaluateNum = 0
      for(let rowIndex = 0; rowIndex < monthColumns.length; rowIndex++){
        const rowString = monthColumns[rowIndex].toString();
        categorys.push(rowString);
        const monthData = data.find(item => item.evaluationDate == rowString);
        if (monthData){
          arr1.push(monthData.score5Num)
          arr2.push(monthData.score4Num)
          arr3.push(monthData.score3Num)
          arr4.push(monthData.score2Num)
          arr5.push(monthData.score1Num)
          this.evaluateNum += monthData.score5Num + monthData.score4Num + monthData.score3Num + monthData.score2Num + monthData.score1Num 
        } else {
          arr1.push(0)
          arr2.push(0)
          arr3.push(0)
          arr4.push(0)
          arr5.push(0)
        }
      }
      xData.push(arr1,arr2,arr3,arr4,arr5)
      this.$refs.lineBar.initEChart(categorys,xData);
    },
  }
}
</script>
<style scoped>
/* @import url(); 引入css类 */
@import url(~@/assets/less/studentFiles.css); 
</style>
